﻿using Microsoft.Extensions.Configuration;

namespace MiniFox.Mail.Configurations
{
    /// <summary>
    /// 
    /// </summary>
    public sealed class MailAccount : IMailAccount
    {
        /// <summary>
        /// 
        /// </summary>
        public MailAccount() { }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("name")]
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("account")]
        public string Account
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("displayAccount")]
        public string DisplayAccount
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("smtpServer")]
        public string SmtpServer
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("port")]
        public int Port
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("password")]
        public string Password
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("displayName")]
        public string DisplayName
        {
            get;
            set;
        }
        /// <summary>
        /// 同步发送超时时间设置(单位：毫秒)
        /// </summary>
        [ConfigurationKeyName("sendTimeout")]
        public int SendTimeout
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("enableSsl")]
        public bool EnableSSL
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("enableAsync")]
        public bool EnableAsync
        {
            get;
            set;
        }
        /// <summary>
        /// 
        /// </summary>
        [ConfigurationKeyName("copySendList")]
        public CopySendSettingCollection CopySendList
        {
            get;
            set;
        } = new();
        /// <summary>
        /// 
        /// </summary>
        public string CCList
        {
            get
            {
                if (this.CopySendList == null)
                    return null;

                List<string> list = new List<string>();
                foreach (CopySendSetting setting in this.CopySendList)
                {
                    if (setting.Blind)
                        continue;
                    list.Add(setting);
                }
                return string.Join(",", list.ToArray());
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string BCCList
        {
            get
            {
                if (this.CopySendList == null)
                    return null;

                List<string> list = new List<string>();
                foreach (CopySendSetting setting in this.CopySendList)
                {
                    if (!setting.Blind)
                        continue;
                    list.Add(setting);
                }
                return string.Join(",", list.ToArray());
            }
        }

    }
}
